home *** CD-ROM | disk | FTP | other *** search
- Path: emerald.tufts.edu!rdorich
- From: rdorich@emerald.tufts.edu (Roberto Dorich)
- Newsgroups: comp.lang.c
- Subject: Re: hex to dec function?
- Date: 26 Feb 1996 17:13:46 GMT
- Organization: Tufts University
- Message-ID: <4gspoa$pp5@d2.tufts.edu>
- References: <4gdh1b$bg@mailhost.mwmicro.com> <Pine.SV4.3.91-heb-2.04.960224052121.13512E-100000@cs.technion.ac.il>
- NNTP-Posting-Host: emerald.tufts.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Or just use my favourite all purpose converter, sscanf(). Something
- like this works:
-
- char *hex = "0x11";
- int num;
-
- sscanf(hex,"0x%x",&num);
-
- --> num contains 17 as expected.
-
- And of course you can go the other way too, using it's counterpart
- sprintf().
-
- Good luck
-
- Roberto
-
- Kohn Emil Dan (emild@cs.technion.ac.il) wrote:
-
-
- : On Tue, 20 Feb 1996 aschlies@citynet.net wrote:
-
- : > Hi There,
- : >
- : > Is there a function that converts HEX to Dec in ANSI C?
- : >
- : > Why re-invent the wheel?
- : >
- : > Thanks
- : > Tony
- : >
- : >
- : >
-
-
- : Try strtol();
-
-
- : Hope this helps.
-
-
- : Regards,
-
-
- : Emil
-
- --
-
- Roberto Dorich o SKI rdorich@ee.cornell.edu
- Electrical Engineering /= EXTREME rdorich@tufts.edu
- Cornell University __/__, dorich@ptc.com
- ----------------------------------------------------------------------
-